Skip to content

Added Happy Number #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 7, 2022
Merged

Conversation

anonimak
Copy link
Contributor

@anonimak anonimak commented Oct 6, 2022

This is actually my first pull request, I start with an easy problem hehe
I hope i can contribute more
thanks,,

Comment on lines 19 to 22
12 + 92 = 82
82 + 22 = 68
62 + 82 = 100
12 + 02 + 02 = 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update this using a ^? The digits together are a bit confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Comment on lines +40 to +41
strNumber = n.toString();
splitNumber = strNumber.split("");
Copy link
Owner

@ignacio-chiazzo ignacio-chiazzo Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another solution that doesn't require translating the integer to a String would be to
get the number, apply mod 10 and divide it by 10, get the digit and repeat the process.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, i don't get it. could you give an example?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last_digit = n % 10 
n = (n - last_digit) / 10

Copy link
Owner

@ignacio-chiazzo ignacio-chiazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing!

Copy link
Owner

@ignacio-chiazzo ignacio-chiazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Comment on lines +40 to +41
strNumber = n.toString();
splitNumber = strNumber.split("");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last_digit = n % 10 
n = (n - last_digit) / 10

Input: s = "abc", indices = [0,1,2]
Output: "abc"
Explanation: After shuffling, each character remains in its position.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this assumes the input indices is a valid input e.g. it cannot be [-1, 1023234234]

@ignacio-chiazzo ignacio-chiazzo merged commit 69ee702 into ignacio-chiazzo:master Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants